package com.ruoyi.system.service.impl;

import java.util.List;
import java.util.UUID;


import com.ruoyi.common.core.domain.entity.RestaurantStoreResourceMove;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.RestaurantStoreResourceMoveMapper;
import com.ruoyi.system.service.IRestaurantStoreResourceMoveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 食材数量变动明细记录Service业务层处理
 *
 * @author wlmes
 * @date 2023-11-24
 */
@Service
public class RestaurantStoreResourceMoveServiceImpl implements IRestaurantStoreResourceMoveService
{
    @Autowired
    private RestaurantStoreResourceMoveMapper restaurantStoreResourceMoveMapper;

    /**
     * 查询食材数量变动明细记录
     *
     * @param id 食材数量变动明细记录ID
     * @return 食材数量变动明细记录
     */
    @Override
    public RestaurantStoreResourceMove selectRestaurantStoreResourceMoveById(Long id)
    {
        return restaurantStoreResourceMoveMapper.selectRestaurantStoreResourceMoveById(id);
    }

    /**
     * 查询食材数量变动明细记录列表
     *
     * @param restaurantStoreResourceMove 食材数量变动明细记录
     * @return 食材数量变动明细记录
     */
    @Override
    public List<RestaurantStoreResourceMove> selectRestaurantStoreResourceMoveList(RestaurantStoreResourceMove restaurantStoreResourceMove)
    {
        return restaurantStoreResourceMoveMapper.selectRestaurantStoreResourceMoveList(restaurantStoreResourceMove);
    }

    /**
     * 新增食材数量变动明细记录
     *
     * @param restaurantStoreResourceMove 食材数量变动明细记录
     * @return 结果
     */
    @Override
    public int insertRestaurantStoreResourceMove(RestaurantStoreResourceMove restaurantStoreResourceMove)
    {
        if(StringUtils.isNull(restaurantStoreResourceMove)) {
            throw new BaseException("新增食材数量变动明细记录失败！");
        }
        restaurantStoreResourceMove.setCreateTime(DateUtils.getNowDate());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        restaurantStoreResourceMove.setCreateBy(String.valueOf(user.getNickName()));
        return restaurantStoreResourceMoveMapper.insertRestaurantStoreResourceMove(restaurantStoreResourceMove);
    }

    /**
     * 修改食材数量变动明细记录
     *
     * @param restaurantStoreResourceMove 食材数量变动明细记录
     * @return 结果
     */
    @Override
    public int updateRestaurantStoreResourceMove(RestaurantStoreResourceMove restaurantStoreResourceMove)
    {
        restaurantStoreResourceMove.setUpdateTime(DateUtils.getNowDate());
        LoginUser loginUser = SecurityUtils.getLoginUser();
        SysUser user = loginUser.getUser();
        restaurantStoreResourceMove.setUpdateBy(String.valueOf(user.getNickName()));
        return restaurantStoreResourceMoveMapper.updateRestaurantStoreResourceMove(restaurantStoreResourceMove);
    }

    /**
     * 批量删除食材数量变动明细记录
     *
     * @param ids 需要删除的食材数量变动明细记录ID
     * @return 结果
     */
    @Override
    public int deleteRestaurantStoreResourceMoveByIds(Long[] ids)
    {
        if(StringUtils.isNull(ids)){
            throw new BaseException("需要删除的食材数量变动明细记录ID为空！");
        }
        return restaurantStoreResourceMoveMapper.deleteRestaurantStoreResourceMoveByIds(ids);
    }

    /**
     * 删除食材数量变动明细记录信息
     *
     * @param id 食材数量变动明细记录ID
     * @return 结果
     */
    @Override
    public int deleteRestaurantStoreResourceMoveById(Long id)
    {
        if(StringUtils.isNull(id)){
            throw new BaseException("需要删除的食材数量变动明细记录ID为空！");
        }
        return restaurantStoreResourceMoveMapper.deleteRestaurantStoreResourceMoveById(id);
    }
}
